/*
    Copyright (c) 2009 Pavol Malosek a.k.a. malo

    This file is part of ComComLib.

    ComComLib is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    ComComLib is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __DLMATH_HPP_INCLUDED__
#define __DLMATH_HPP_INCLUDED__

#include <stdint.h>
#include <list>

#include <lcc/device_info.hpp>

namespace lcc
{
    //  Returns number of one-s in byte;
    unsigned int act_bits (uint8_t byte_);

    //  Convert datalogger .FLOAT format to PC float format.
    float dot_float_to_float (uint8_t exp_, uint8_t b0_, uint8_t b1_, 
        uint8_t b2_);

    //  Conver BCD to int.
    uint8_t bcd_to_uint8 (uint8_t bcd_value_);

    //  Calculate temperature for pt1000 sensor.
    float calc_temp_Pt_1000 (calc_constants_t *constants_, 
        unsigned int adc_value_);

    //  Calculate relative humidity. T is used for compensation.
    float calc_hum (calc_constants_t *constants_, float T_, 
        unsigned int adc_value_, bool valid_T_ = true);

    //  Calculate real values from ADC.
    void adc_to_real_values (device_info_t *device_info_, 
        std::list<record_t> &records_);
}
#endif
